﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class ShowFile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string sql = "SELECT * FROM CourseDocumentInfo WHERE CourDocumentID = '" + Request.QueryString["ID"] + "'";
        ConnectionStringSettings connObj = ConfigurationManager.ConnectionStrings["smsConnectionString"];
        string connectionString = connObj.ConnectionString;
        SqlConnection objConnection = new SqlConnection(connectionString);
        SqlCommand command = new SqlCommand(sql, objConnection);
        objConnection.Open();
        SqlDataReader dr = command.ExecuteReader();
        if (dr.Read())
        {
            Response.Clear();
            Response.AddHeader("Content-Type", dr["CourDocumentType"].ToString());
            Response.BinaryWrite((byte[])dr["CourDocumentUpload"]);
        }
        dr.Close();
        objConnection.Close();

    }
}
